<!-- Set this_pages_navbar  -->
{% comment %}
Here, we loop through site.data for the current view
to set two variables:
	1. this_pages_navbar - a object containing this page's navbar
	2. navbars - a list of this site's toplevel navbars sorted by navbar.order

The code is a little roundabout for a few reasons:
	- liquid doesn't provide a simple way to create an empty array,
	so we just split an empty string.
	- liquid stores the navbars (in site.data[version].navbars) as
	a list keyed by the filename. We don't really care about the filename
	here, so we just need the data field. But, liquid doesn't provide a
	simple way to 'iteritems', so we have to manually loop through and access
	the	2nd item.
	- liquid also has a bug where it truncates after first `.` of a directory
	name in _data (i.e. _data/v0.1 will be stored as data.v0). Until that
	bug's fixed, we store version data in _data/v0_1 and do a string replace
	to find the right data.
{% endcomment %}

{% assign current_page = page.path | replace_first: page.version,"" | split: "/" %}
{% assign current_page = current_page[1] | prepend: "/" %}

{% capture version %}{{ page.version | replace: ".","_" }}{% endcapture %}

{% assign unsorted_navbars = "" | split:"|" %}
{% for navbars_hashmap in site.data[version].navbars %}
	{% assign navbar = navbars_hashmap[1] %}
	{% assign unsorted_navbars = unsorted_navbars | push: navbar %}
	{% assign navbar_size = navbar.path | size %}
	{% if current_page == navbar.path %}
		{% assign this_pages_navbar = navbar %}
	{% endif %}
{% endfor %}
{% assign navbars = unsorted_navbars | sort:"order" %}


<!Doctype html>
<html id="docs" class="{{this_pages_navbar.bigheader}}">

{% include head-header.html %}

<script type="text/javascript">
function redirect(version) {
	window.location = "{{site.baseurl}}/" + version + "/introduction"
}
</script>
<!--  HERO  -->
<section id="hero" class="dark-text">
	<h1>{{ this_pages_navbar.bigheader }}</h1>
	<div style="float: left;"><h5>{{ this_pages_navbar.abstract }}</h5></div>
	<!--	Ideally here, we would have a drop-down button to select the version
			For now, we'll just print the current version -->
	<div style="float: right;">
		<h5>Viewing Version: <b>{{ page.version }}</b></h5>
		<span>View other release:</span>
		<span class="dropdown">
			<select onchange="redirect(this.value)">
				<option value="v2.0" {% if page.version == "v2.0" %}{{"selected"}}{% endif %}>v2.0</option>
				<option value="v1.6" {% if page.version == "v1.6" %}{{"selected"}}{% endif %}>v1.6</option>
				<option value="v1.5" {% if page.version == "v1.5" %}{{"selected"}}{% endif %}>v1.5</option>
				<option value="master" {% if page.version == "master" %}{{"selected"}}{% endif %}>master</option>
			</select>
		</span>
	</div>
	<div style="clear: both;"></div>
	<div id="vendorStrip" class="dark-text">
		<ul>
			{% for navbar in navbars %}
				<li><a href="{{site.baseurl}}/{{page.version}}{{navbar.path}}" {% if this_pages_navbar == navbar %}class="YAH"{% endif %}>{{ navbar.bigheader | upcase }}</a></li>
			{% endfor %}
		</ul>
	</div>
</section>

<section id="encyclopedia">
	<div id="docsToc">
        <div class="pi-accordion">
				{% include sidebar.html sidebar=this_pages_navbar.toc %}
        </div> <!-- /pi-accordion -->
		<button class="push-menu-close-button" onclick="kub.toggleToc()"></button>
	</div> <!-- /docsToc -->
	<div id="docsContent" style="float:none; display:table-cell; width:auto; max-width:8in;">
		{% if page.version == "master"  %}
			<div style="text-align: center; color: #8a6d3b; background-color: #fcf8e3; border-color: #faebcc; padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px;">
				<p><b>Warning: You are viewing <code>master</code> documentation.</b></p>
				<p>To view documentation for the last stable production release, see the <a href="/v1.6/introduction/">v1.6 documentation</a>.</p>
			</div>
		{% elsif page.version == "v2.0" %}
			<div style="text-align: center; color: #8a6d3b; background-color: #fcf8e3; border-color: #faebcc; padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px;">
				<p><b>Warning: You are viewing Calico v2.0 Beta documentation.</b></p>
				<p>Calico v2.0 Beta is not recommended for production.</p>
				<p>To view documentation for the last stable production release, see the <a href="/v1.6/introduction/">v1.6 documentation</a>.</p>
			</div>
		{% endif %}
    	{% if notitle != "true" %}<h1>{{ title }}</h1>{% endif %}
		{{ content }}
	</div>
</section>

{% include footer.html %}

<button class="flyout-button" onclick="kub.toggleToc()"></button>

<style>
	.cse .gsc-control-cse, .gsc-control-cse, {
		padding: 0;
	}
	.gsc-control-cse table, .gsc-control-cse-en table {
		margin:0px !important;
	}

	.gsc-above-wrapper-area {
		border-bottom: 0;
	}
</style>
</body>
</html>
